home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libkmid / gusout.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.1 KB  |  181 lines

  1. /*  gusout.h   - class gusOut which implements support for Gravis
  2.          Ultrasound cards through a /dev/sequencer device
  3.     This file is part of LibKMid 0.9.5
  4.     Copyright (C) 1998,99,2000  Antonio Larrosa Jimenez
  5.     LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html
  6.  
  7.     This library is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU Library General Public
  9.     License as published by the Free Software Foundation; either
  10.     version 2 of the License, or (at your option) any later version.
  11.  
  12.     This library is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     Library General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU Library General Public License
  18.     along with this library; see the file COPYING.LIB.  If not, write to
  19.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20.     Boston, MA 02110-1301, USA.
  21.  
  22.     Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
  23.  
  24. ***************************************************************************/
  25. #ifndef _GUSOUT_H
  26. #define _GUSOUT_H
  27.  
  28. #include <libkmid/midiout.h>
  29. #include <libkmid/voiceman.h>
  30.  
  31. /**
  32.  * Gravis Ultrasound synthesizer output class . This class is used to send midi
  33.  * events to synthesizers on GUS cards.
  34.  *
  35.  * GUSOut inherits MidiOut and supports the same simple API.
  36.  *
  37.  * The recommended way to use this class is by using a DeviceManager
  38.  * object, and use the DeviceManager::setPatchesToUse() member which will
  39.  * call the setPatchesToUse() member in this class.
  40.  *
  41.  * @short Sends MIDI events to GUS synths
  42.  * @version 0.9.5 17/01/2000
  43.  * @author Antonio Larrosa Jimenez <larrosa@kde.org>
  44.  */ 
  45. class GUSOut : public MidiOut
  46. {
  47.   private:
  48.     class GUSOutPrivate;
  49.     GUSOutPrivate *di;
  50.  
  51.     int patchloaded[256];
  52.     int nvoices;
  53.  
  54.     int use8bit; // Use 8 bit patches, instead of 16 bits to use less memory
  55.     VoiceManager *vm;
  56.  
  57.     int totalmemory; // Total memory in soundcard
  58.     int freememory; // Free memory
  59.  
  60.  
  61.     void patchesLoadingOrder(int *patchesused,int *patchesordered);
  62.     const char *patchName(int pgm);
  63.  
  64.   public:
  65.     /**
  66.      * Constructor. See MidiOut::MidiOut() for more information.
  67.      */
  68.     GUSOut(int d=0,int total =12);
  69.  
  70.     /**
  71.      * Destructor.
  72.      */
  73.     ~GUSOut();
  74.  
  75.     /**
  76.      * See MidiOut::openDev()
  77.      */
  78.     virtual void openDev    (int sqfd);
  79.  
  80.     /**
  81.      * See MidiOut::closeDev()
  82.      */
  83.     virtual void closeDev    (void);
  84.  
  85.     /**
  86.      * See MidiOut::initDev()
  87.      */
  88.     virtual void initDev    (void);
  89.  
  90.     /**
  91.      * See MidiOut::noteOn()
  92.      */
  93.     virtual void noteOn        ( uchar chn, uchar note, uchar vel );
  94.  
  95.     /**
  96.      * See MidiOut::noteOff()
  97.      */
  98.     virtual void noteOff    ( uchar chn, uchar note, uchar vel );
  99.  
  100.     /**
  101.      * See MidiOut::keyPressure()
  102.      */
  103.     virtual void keyPressure    ( uchar chn, uchar note, uchar vel );
  104.  
  105.     /**
  106.      * See MidiOut::chnPatchChange()
  107.      */
  108.     virtual void chnPatchChange    ( uchar chn, uchar patch );
  109.  
  110.     /**
  111.      * See MidiOut::chnPressure()
  112.      */
  113.     virtual void chnPressure    ( uchar chn, uchar vel );
  114.  
  115.     /**
  116.      * See MidiOut::chnPitchBender()
  117.      */
  118.     virtual void chnPitchBender    ( uchar chn, uchar lsb,  uchar msb );
  119.  
  120.     /**
  121.      * See MidiOut::chnController()
  122.      */
  123.     virtual void chnController    ( uchar chn, uchar ctl , uchar v ); 
  124.  
  125.     /**
  126.      * It's an empty function, as GUS synths don't support System Exclusive
  127.      * messages
  128.      */
  129.     virtual void sysex        ( uchar *data,ulong size);
  130.  
  131.     /**
  132.      * See DeviceManager::setPatchesToUse() . All the information about this
  133.      * member is explained there because it's (for now) just a simple call to this
  134.      * function when the device used is a GUS device, and you're supposed to use
  135.      * a DeviceManager object instead of a GUSOut object except in rare ocassions.
  136.      *
  137.      * @see patch()
  138.      * @see loadPatch()
  139.      */
  140.     void setPatchesToUse(int *patchesused);
  141.  
  142.     /**
  143.      * Loads a single patch on the synthesizer memory.
  144.      * @param pgm is the number of the GM patch when pgm is between 0 and 127.
  145.      * Values from 128 to 255 are used to represent the percussion instruments.
  146.      * @return 0 if OK and -1 if there was an error (patch not found, not enough
  147.      * memory, etc.)
  148.      *
  149.      * @see patch()
  150.      * @see setPatchesToUse()
  151.      */
  152.     int loadPatch  (int pgm);
  153.  
  154.     /**
  155.      * Returns p if the patch with number p has been correctly loaded.
  156.      * In the case it hasn't been loaded, it returns the number of another patch
  157.      * that is loaded and that should be used instead.
  158.      *
  159.      * @see loadPatch()
  160.      * @see setPatchesToUse()
  161.      */
  162.     int patch(int p); 
  163.  
  164.   private:
  165.     static const char *GUS_patches_directory;
  166.     static int delete_GUS_patches_directory;
  167.  
  168.   public:
  169.     /**
  170.      * Sets the directory where the GUS patches are stored, that is, where the
  171.      * acpiano.pat, ... files can be found.
  172.      *
  173.      * It will store a copy of the parameter, so you should delete the memory
  174.      * used by the parameter you passed.
  175.      */ 
  176.     static void setGUSPatchesDirectory(const char *dir);
  177.  
  178. };
  179.  
  180. #endif
  181.